package com.dragon.repository.mapper;

import com.dragon.repository.entity.RejectedProduct;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 退货产品表 Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2023-12-06
 */
@Mapper
public interface RejectedProductMapper extends BaseMapper<RejectedProduct> {


    @Select("SELECT a.*,b.`name` as name ,b.specification ,c.`name` as unitName, b.material as material, b.remark as remark, " +
            " dpp.num as contractNum FROM dragon_rejected_product a " +
            "LEFT JOIN dragon_vendor_products b ON  a.product_id = b.id " +
            "left join dragon_produce_products dpp on dpp.produce_id = #{produceId} and dpp.quotes_product_id = a.product_id " +
            "LEFT JOIN dragon_dictsort_detail c ON c.code_type = 'unitCode' AND b.unit = c.id " +
            " WHERE a.rejected_id = #{id}")
    List<RejectedProduct> selectProductList(Integer id, Integer produceId);

}
